<template>
	<scroll-view scroll-x="true" class="scroll" >
		<view v-if="addShow" class="scroll-item">
			<view class="content-item" @click="showClasses">
				<u-icon name="plus-circle-fill" size="60"></u-icon>
			</view>
		</view>
		<view v-for="(item,index) in childrenList" class="scroll-item" :key="index">
			<view class="content-item" @click="childrenItemClick(index)">
				<children-head-view
					:imgUrl="item.imgUrl"
					:gender="item.gender"
					size="mini"/>
				<text class="name">{{item.name}}</text>
			</view>
		</view>
	</scroll-view>
</template>

<script>
	import ChildrenHeadView from '@/components/children-head-view.vue'
	export default {
		name:"ChildrenListView",
		components: {
			ChildrenHeadView
		},
		props: {
			childrenList: {
				type: Array,
				default () {
					return []
				}
			},
			addShow: {
				type: Boolean,
				default () {
					return true
				}
			}
		},
		data() {
			return {
				
			};
		},
		methods: {
			showClasses() {
				this.$emit('showClasses');
			},
			
			childrenItemClick(index) {
				if (this.addShow) {
					this.$emit('itemClick', index)
				}
			},
		}
	}
</script>

<style lang="scss">
	.scroll{
		white-space: nowrap;
		background-color: #FFFFFF;
		border-radius: 20rpx
	}
	
	
	.scroll-item{
		display: inline-block;
		width: 100rpx;
		
		.content-item{
			height: 120rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			
			.name{
				font-size: 20rpx;
			}
		}
	}
</style>
